// components/MyRecommend/recommend.js
const api = require('../../api/index')
Component({
  data: {
    arr: []
  },
  // 生命周期的
  lifetimes: {
    // 组件创建了的钩子函数 （初始化）
    created() {
      // 调用推荐歌单接口... 
      api.getrecommendList()
        .then(
          content => {
            let {
              code,
              result
            } = content;
            let rocommend = result
            rocommend = result.slice(0, 6)
            if (code == 200) {
              let arr = rocommend.map(item => {
                return {
                  // xxx:item.xxx
                  playCount: (item.playCount / 10000).toFixed(1) + '万',
                  id: item.id,
                  name: item.name,
                  picUrl: item.picUrl,
                  trackNumberUpdateTime: item.trackNumberUpdateTime,
                  trackCount: item.trackCount
                }
              })
              // console.log("--->",arr);
              // 赋值
              this.setData({
                arr: arr
              })

            }
          }
        )
    }
  },

  
})